package com.meixiang.adapter.home;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.meixiang.R;


import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * @author yinsujun  Created at 2016/5/5 13:53
 */
public class CheckStagingAdapter extends RecyclerView.Adapter<CheckStagingAdapter.ViewHolder> {

    private Context context;

    public CheckStagingAdapter(Context context) {
        this.context = context;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.activity_check_staging_detail_list_item, parent, false);
        ViewHolder viewHolder = new ViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(final ViewHolder holder, final int position) {
        if (mOnItemClickListener != null) {
            holder.itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    int pos = holder.getLayoutPosition();
                    mOnItemClickListener.onItemClick(holder.itemView, pos);

                }
            });
        }
    }

    @Override
    public int getItemCount() {
        return 8;
    }

    private OnItemClickListener mOnItemClickListener;

    public void setOnItemClickListener(OnItemClickListener mOnItemClickListener) {
        this.mOnItemClickListener = mOnItemClickListener;
    }

    public interface OnItemClickListener {
        void onItemClick(View view, int position);
//      void onItemLongClick(View view , int position);
    }


    class ViewHolder extends RecyclerView.ViewHolder {
        @Bind(R.id.staging_detail_tv_type)
        TextView tvType;
        @Bind(R.id.staging_detail_tv_money)
        TextView tvMoney;
        @Bind(R.id.staging_detail_tv_money_explain)
        TextView tvMoneyExplain;
        @Bind(R.id.staging_detail_tv_time)
        TextView tvTime;
        @Bind(R.id.staging_detail_tv_status)
        TextView tvStatus;

        public ViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);

        }
    }

}
